///
/// This is the Event handler for Save Button. When the user clicks on the save button, The example saves the primary key
/// in a temporary ID variable, allowing you to add custom code that uses this variable.
///
public override void ${Button Control}_Click(object sender, ImageClickEventArgs args)
{
// Please remove the above code: SaveButton_Click_Base(sender, args) for this customization to run successfully.
// Set shouldRedirect to true
bool shouldRedirect = true;
// Start Transaction and save Order record control data
try
{
// Start Transaction and save data
DbUtils.StartTransaction();
this.SaveData();
this.CommitTransaction(sender);
// Get the record control.
${Table Name}Record rec= this.${Record Control Class}.GetRecord();
// Retrieve the primary key and do more code customization like passing the retrieved value to another page, stored procedure and so on.
String tempId = rec.${Primary Key Field}.ToString();
// For example, redirect to another page by passing the saved record's ID
this.Page.Response.Redirect("../OtherPages/SomeOtherPage.aspx&ID=" + tempId );
}
catch (Exception ex)
{
shouldRedirect = false;
// If there is an Exception then display an alert message
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
this.RollBackTransaction(sender);
}
finally
{
DbUtils.EndTransaction();
}
// If shouldRedirect then save controls to session and redirect
if (shouldRedirect)
{
this.ShouldSaveControlsToSession = true;
this.RedirectBack();
}
}
|